<script setup stype="ts">
import { ref, onMounted } from "vue";
const sum = ref(0);
// 在组件挂载后执行累加逻辑
onMounted(() => {
  for (let i = 1; i <= 100; i++) {
    sum.value += i;
  }
});
</script>
内部资料
<template>
  <div>1 到 100 的累加值是：{{ sum }}</div>
</template>
